//支付
	setMaxDigits(130);
  	var key = new RSAKeyPair("10001","","8b33d1d7027cb8f910d538d6cd1e0c7344b3fc3728c83f39fec7d4149a4332f740ba6867ce585addbd3c6e3df6cac316956fc316843cb62604495fdfbd11ab607b9696e04ca7e1afda894d39f240431d3ae9b8fe3af6d3c6f352e4cd70f2c55669bb4e0d77ec22b56c00e412b52ec7e1f092b124d4bd67754b7bb43bddca8441");
	//付款成功 发送短信， 跳转到机票查询页
  	function toIndex()
	{var  batchId = $("#batchId").val();;
  	window.location.href ="tc.do?m=sendSms&batchId="+batchId;
	}
	function toOrder()
	{
  	window.location.href ="tc.do?m=sto";
	}
	function payTicketOrder2(){
		var pwdType;	
		var mgpwd;
		if($("#pc_pwdkeybon").val()==""){
			$("#showMSG1").attr("style","display:");
			$("#showMSG1_msg").html("请输入支付密码");
			$("#pc_pwdkeybon").val("");
			$("#e_password").val("");
			$("#pc_pwdkeybon").focus();
		} else if($("#pc_pwdkeybon").val().length < 6){
			$("#showMSG1").attr("style","display:");
			$("#showMSG1_msg").html("请输入六位密码");
			$("#pc_pwdkeybon").val("");
			$("#e_password").val("");
			$("#pc_pwdkeybon").focus();
		} else if($("#mobilevalicode").val()==""){
			$("#showMSG1").attr("style","display:");
			$("#showMSG1_msg").html("请输入验证码");
			$("#yzkeybon").val("");
			$("#yzkeybon").focus();
		}else{
			if($("#e_password").val()!=""){
				mgpwd=$("#e_password").val();
				pwdType="0";
			}else{
				mgpwd=strEnc($("#pc_pwdkeybon").val());
				pwdType="1";
			}
			if(checkValiCode($('#yzkeybon').val())){
				var total ;
				var  batchId = $("#batchId").val();;
				var bz = "9013";
				
				var fromorderdetail = $("#fromorderdetail").val();
				if(fromorderdetail=='Y'){
					total = $("#priceAll").val();
				}else{
					var money1 = $("#order1").val();
					var money2 = $("#order2").val();
					if(money2==undefined){
						money2="0";
					}
					 total = parseInt(jQuery.trim(money1))+parseInt(jQuery.trim(money2));
				}
				var transAmt = parseFloat(total) * 100;
				var orderName = "机票预订:机票预订支付"+transAmt+"元";
				var merchantId = $("#merchantId").val();
				 $.ajax({
				    	type:"post",//请求方式
				    	url:"appCenter.do",//发送请求地址
				    	data:{//发送的数据
				    		m:"ticketPay_hb",
				    		orderId:batchId,
				    		orderType:'9013',
				    		orderName:orderName,
				    		bz:bz,
				    		transAmt:transAmt,
				    		pwdType:pwdType,
				    		mgpwd:mgpwd,
				    		merchantId:merchantId
				    	},
				    	dataType:"json",  
				    	//请求成功后的回调函数有两个参数
				    	success:function(data,textStatus){
				    		
				    		if ('1' == data.result) {
				    			//alert(batchId);
				    			EV_closeAlert();
				    			ymPrompt.succeedInfo(document.getElementById('txt').innerHTML,500,200,null,handler2);
				    		} else {
				    			
				    			$("#showMSG1").attr("style","display:");
								$("#showMSG1_msg").html(data.resultdes);
								setTimeout('toOrder()',3000);  //单位毫秒
				    		}
				    	}
				    });
			}else{
				$("#showMSG1").attr("style","display:");
				$("#showMSG1_msg").html("请输入正确的验证码");
				document.getElementById("divImg2").src="randomcode?time="+new Date().getTime();
				$("#yzkeybon").val("");
				$("#yzkeybon").focus();
			}	
		}

	}
	function handler2(tp){
		if(tp=='ok'){
			toIndex();
		}
		if(tp=='cancel'){
			cancelFn();
		}
		if(tp=='close'){
			closeFn();
		}
	}
		function cancelFn(){
			toIndex();
			//ymPrompt.alert("点击了'取消'按钮");
		}
		function closeFn(){
			toIndex();
			//ymPrompt.alert("点击了'关闭'按钮");
		}
		
	//改变验证码
	function changeCode(){
		document.getElementById("divImg1").src="randomcode?time="+new Date().getTime() ; 
	}
	function changeCode2(){
		document.getElementById("divImg2").src="randomcode?time="+new Date().getTime() ; 
	}	
	//获取短信验证码
	function getMobileCode(){
		if($("#tmobile").val()==""){
			$("#showMSG1").attr("style","display:");
			$("#showMSG1_msg").html("请输入手机号");
			$("#tmobile").val("");
			$("#tmobile").focus();
		}
		$.ajax({   
			   type: "POST",   
			   url: encodeURI("getMobileCode.shtml?mobile="+$('#tmobile').val()), 
			   dataType:"json", 
			   async:false , 
			   success: function(data){
				  if(data.result==1){
					  $("#token").val(data.token);
				  }else if(data.result==2){
					  $("#showMSG1").attr("style","display:");
					  $("#showMSG1_msg").html(data.resultdes);
				  }  
			   },
			   error:function(){
			   	   alert("error!");
			   }	 
			});
	}
	
	//校验验证码
	function checkValiCode(code){
		var result;
		$.ajax({   
			   type: "POST",   
			   url: encodeURI("checkValiCode.shtml?code="+code), 
			   dataType:"text", 
			   async:false , 
			   success: function(data){
				   if(data=='1'){
					   result = true;
				   }else{			
					   result = false;
				   }
			   },
			   error:function(){
			   	   alert("error!");
			   }	 
			});
		return result;
	}	
	
	/**
	 * 控件调用机票支付
	 */
	function payTicketOrder() {
		EV_closeAlert();
		//var orderId = $("#orderId").val();
		var batchId = $("#batchId").val();
		var bz = "9013";
		//var money = $("#priceAll").val();
		var fromorderdetail = $("#fromorderdetail").val();
		var total;
		if(fromorderdetail=='Y'){
			total = $("#priceAll").val();
		}else{
			var money1 = $("#order1").val();
			var money2 = $("#order2").val();
			if(money2==undefined){
				money2="0";
			}
			 total = parseInt(jQuery.trim(money1))+parseInt(jQuery.trim(money2));
		}
		
		var orderName="机票预订:机票预订支付"+total+"元";
		var jsonCreditCard = getEcardToneJson(4150);
		var miugo = document.getElementById("Miugo");
		jsonCreditCard.OrderId = batchId;
		jsonCreditCard.OrderType = "9013";
		jsonCreditCard.TransAmt = parseFloat(total)*100 ;
		jsonCreditCard.CAIC = $("#merchantId").val();
		jsonCreditCard.OrderName= orderName;
		jsonCreditCard.UseCoupon = "N";
		jsonCreditCard.SpecialAmt = "0";
		jsonCreditCard.BZ=bz;
		miugo.RegCallback(creditCardPayCallBack);
		miugo.Trade(jsonCreditCard);
	}
	
	//机票付款回调
	function creditCardPayCallBack(args){
		var json = JSON.parse(args);
		//var returnUrl = $("#returnUrl").val();
		if(json != null && json.Status == 0){
			ymPrompt.succeedInfo(document.getElementById('txt').innerHTML,500,200,null,handler2);
			//window.location.href = returnUrl;
		} else{
			 toOrder();//跳转到机票查询页
		}
	}
	
	function changMobileType(){
		if($("#loginPass").val()=='0'){
			$("#loginPass1_div").show();
			$("#loginPass2_div").hide();
		}
		if($("#loginPass").val()=='1'){
			$("#loginPass2_div").show();
			$("#loginPass1_div").hide();
		}
	}

	//验证账户获取卡号
    function getCardNo(){
    	EV_closeAlert();
    	var json = getEcardToneJson(29749);
		var miugo = document.getElementById("Miugo");
		json.CAIC=CAIC;
		miugo.RegCallback (getCardNoCallBack);
		miugo.Trade(json);
    }
	
	//验证账户ActiveX回调函数
	function getCardNoCallBack(args){
		var json = JSON.parse(args);
		//alert(args);
		if(json.Status == 4){
			alert("未注册卡,请先注册！");
			window.location.href="reg.do";
			return;
		}

		if(json != null && json.Status == 0&&"Y"==json.CardStatusUserSet&&"Y"==json.IsAccValid&&"00"==json.CardStatus){
			$.ajax({
		    	type:"post",//请求方式
		    	url:"reg.do",//发送请求地址
		    	data:{//发送的数据
		    		m:"g",
		    		cardNo:json.CardNum
		    	},
		    	dataType:"json",  
		    	//请求成功后的回调函数有两个参数
		    	success:function(data,textStatus){
		    		if(""!=data.mobileStr || ""!=data.mailStr){
		    			document.getElementById("mobile").value=data.mobileStr;
		    			document.getElementById("mail").value=data.mailStr;
	    				document.getElementById("name").value=data.name;
		    			document.getElementById("idType").value=data.idType;
		    			document.getElementById("idNum").value=data.idNum;
		    			EV_closeAlert();
		    			if(""!=data.mobileStr){
		    				time=300;
			    			timeOut();
			    			EV_modeAlert('cpassword');
		    			}else if(""!=data.mailStr && ""==data.mobileStr){
		    				time=300;
			    			timeOut();
		    				EV_modeAlert('mpassword');
		    			}	
		    		}else{
		    			alert("没有查到手机号或邮件地址");
		    			return;
		    		}
		    	}
		    });
		}else{
			
		}
	}
	
	//清空session
	function deleteSession(){
		var check=""; 
			  $.ajax({
		    	type:"post",//请求方式
		    	url:"reg.do",//发送请求地址
		    	data:{//发送的数据
		    		m:"d",
		    		check:check
		    	}
		    });
	}
	
	//重发手机短信
	function resendPhone(){
		var phone=document.getElementById("mobile").value;
		var name=document.getElementById("name").value;
		var mail=document.getElementById("mail").value;
		$.ajax({
			type : "post",//请求方式
			url : "reg.do",//发送请求地址
			data : {//发送的数据
				m : "g",
				sphone : phone,
				sname : name,
				smail : mail
			}
		});
		document.getElementById("resendp").onclick="";
		document.getElementById("resendp1").onclick="";
		time=300;
		timeOut();
		
	}
	var timeHandler = 0;
	var time=300;
	function timeOut() {
		
		timeHandler = window.setTimeout('timeOut()', 1000);
		if (time > 0) {
			document.getElementById("resendp").value = time + "秒";
			document.getElementById("resendp1").value = time + "秒";
			time--;
		} else {
			if(time==0){
				clearTimeout(timeHandler);
				deleteSession();
				resendp.value = "再次发送短信";
				resendp1.value = "再次发送短信";
				document.getElementById("resendp").onclick=function(){resendPhone();};
				document.getElementById("resendp1").onclick=function(){resendPhone();};
				return;
			}
		}
	}
	
	//重置密码
	function ChangePassWord()
	{
		var chkCode = document.getElementById("t_chkcode").value;
		var chkCode1 = document.getElementById("t_chkcode1").value;
		var name = document.getElementById("name").value;
		var idType = document.getElementById("idType").value;
		var idNum = document.getElementById("idNum").value;
		if(IsEmpty(chkCode)&&IsEmpty(chkCode1)){
			alert("请输入验证码.");
			return;
		}else{
			$.ajax({
		    	type:"post",//请求方式
		    	url:"reg.do",//发送请求地址
		    	data:{//发送的数据
		    		m:"tp"
		    	},
		    	dataType:"json",  
		    	//请求成功后的回调函数有两个参数
		    	success:function(data,textStatus){
		    		if(""!=data.check && (data.check==chkCode||data.check==chkCode1)){
		    			//通讯
		    			var json = getEcardToneJson(28933);
		    			var miugo = document.getElementById("Miugo");
		    			json.OprFlag="03";
		    			json.NameFlag="Y";
		    			json.Name=name;
		    			json.IdType=idType;
		    			json.IdNum=idNum;
		    			miugo.RegCallback(ChangePassWordCallBack);
		    			miugo.Trade(json);
		    		}else{
		    			alert("请输入正确验证码！");
		    			return;
		    		}
		    	}
		    });
		}
		
	}
	//重置密码回调函数
	function ChangePassWordCallBack(args){
		var json = JSON.parse(args);
		if(json != null && json.Status == 0){
			alert("恭喜您，密码重置成功");
			closePopup();
		}else{
			//alert("非常抱歉，修改密码失败，请重试.");
		}
	}
	
	//关闭
	function closePopup(){
		EV_closeAlert();
		time=0;
		timeHandler = window.setTimeout('timeOut()', 1000);
		if(time==0){
			clearTimeout(timeHandler);
			deleteSession();
			document.getElementById("resendp").onclick="";
			document.getElementById("t_chkcode").value="";
			document.getElementById("resendp1").onclick="";
			document.getElementById("t_chkcode1").value="";
			return;
		}
	}
	
	//进入邮箱
	function receiveMail(){
		var mail=document.getElementById("mail").value;
		var hash={ 
			'qq.com': 'http://mail.qq.com', 
			'gmail.com': 'http://mail.google.com', 
			'sina.com': 'http://mail.sina.com.cn', 
			'163.com': 'http://mail.163.com', 
			'126.com': 'http://mail.126.com', 
			'yeah.net': 'http://www.yeah.net/', 
			'sohu.com': 'http://mail.sohu.com/', 
			'tom.com': 'http://mail.tom.com/', 
			'sogou.com': 'http://mail.sogou.com/', 
			'139.com': 'http://mail.10086.cn/', 
			'hotmail.com': 'http://www.hotmail.com', 
			'live.com': 'http://login.live.com/', 
			'live.cn': 'http://login.live.cn/', 
			'live.com.cn': 'http://login.live.com.cn', 
			'189.com': 'http://webmail16.189.cn/webmail/', 
			'yahoo.com.cn': 'http://mail.cn.yahoo.com/', 
			'yahoo.cn': 'http://mail.cn.yahoo.com/', 
			'eyou.com': 'http://www.eyou.com/', 
			'21cn.com': 'http://mail.21cn.com/', 
			'188.com': 'http://www.188.com/', 
			'foxmail.coom': 'http://www.foxmail.com', 
			'miugo.net':'http://mail.miugo.net:85/'
		};
		
		var url = mail.split('@')[1]; 
		window.open(hash[url]);
	}
	
	//登录
	function loginMain(cardNo, uuid){
		 $.ajax({
		    	type:"post",//请求方式
		    	url:"login.do",//发送请求地址
		    	data:{//发送的数据
		    		m:"loginMain",
		    		cid:cardNo,
		    		lid:uuid
		    	},
		    	dataType:"json",  
		    	//请求成功后的回调函数有两个参数
		    	success:function(data,textStatus){
		    		if ('1' == data) {
		    			window.location.href='ticket.do?m=order';
		    			EV_closeAlert();
		    		}
		    	}
		    });
	}
